#ifndef __OS_MUTEX_H
#define __OS_MUTEX_H


#include "os_config.h"
#include "os_core.h"

#ifdef __cplusplus
extern "C" {
#endif


typedef volatile struct os_mutex OS_MUTEX_MEMORY
{
    uint8_t                      holder;        // Mutex holder
}os_mutex_st;


#define OS_MUTEX_INIT()         {0}
#define os_mutex_lock(p_mutex)  OS_TASK_WAIT(os_mutex_trylock(p_mutex) == 0)
extern int os_mutex_init(os_mutex_st  * const mutex);
extern int os_mutex_unlock(os_mutex_st  * const mutex);
extern int os_mutex_trylock(os_mutex_st  * const mutex);


#ifdef __cplusplus
}
#endif
#endif
